Introduction

Previously you were made aware of the importance of keeping a coding project within a remote repository, as this facilitates collaboration between multiple developers and ensures that a project is not lost should something go wrong with the local version.

In this exercise, you will practice the steps for committing a local project to the remote repository on GitHub.

Scenario

You’ve almost finished setting up a project for the Little Lemon app! You’ve set up a local repository and you’ve started a new project in Expo, now the final step is to commit the project to the remote repository on GitHub.

Instructions

Step 1: Browse to the Expo application root folder

Begin by opening the terminal, then navigate to your Expo application root folder with the following command:

cd little-lemon

Step 2: Set the remote URL to point to the GitHub repository you created in a previous exercise

Type the following command below to set the remote URL to point to your GitHub repository.

git remote add origin git@github.com:yourUserName/little-lemon.git

Note : The text yourUserName in this line should be replaced with your actual GitHub username.

Step 3: Change the main branch from “master” to “main”

If the default branch is already "main" you can skip this step.

Otherwise, enter the next command in the terminal:

git branch –M main

Step 4: Explore git log

Enter the following command to check the git log and verify that an initial commit is automatically generated by the create-expo-app CLI tool:

git log

Step 5: Push the local repository to GitHub

Next, enter the following command:

git push –u origin main

Step 6: Log in to GitHub and check that the project is uploaded

Navigate to https://github.com/yourUserName/little-lemon and verify that your project file structure reflects in the UI.

Note: replace 'yourUserName' in the URL with your actual GitHub username.

Step 7: Create a new branch

Use the following Git command to create a new branch:

git checkout –b <branch-name>

Note : The text <branch-name> in this line should be replaced with your branch name. Be sure to omit the brackets as well.

Step 8: Create a new file called README.md at the root level

From the root level of your Expo application folder, create a new file named README.md and type the following markdown text inside it:

#little-lemon

Step 9: Add the new changes to the stage

In the Git terminal, enter the command git add to enter the changes to the stage.

Step 10: Check the status

In the Git terminal, enter the command git status to check the Git status.

Step 11: Commit the changes

Commit the changes with the following Git command:

git commit –m "message"

Note : You should replace "message" with your own personal comment to describe the nature of the changes.

Step 12: Push the changes to the GitHub repository

With the changes committed, it’s time to push the changes to the repository. To do this, use the following command:

git push –u origin <branch-name>

Note : The text <branch-name> in this line should be replaced with your branch name. Be sure to omit the brackets as well.

Step 13: Open the repository in GitHub

The repository page displays the Compare & pull request button. Go ahead and select it.

Step 14: Create pull request

On the repository page, the changes committed displays. So, select the Create & pull request button.

Step 15: Merge pull request

Review the changes and confirm by pressing the Merge pull request button.

Step 16: Change to the main branch in the local repository

Go back to the terminal and enter the following command:

git checkout main

Step 17: Update the main branch

Finally, update the main branch with the git pull command.

Conclusion

In this exercise, you successfully pushed the React Native project files to the GitHub repository.